
<?php
	$manhasx=$_POST["manhasx"];
	$tennhasx=$_POST["tennhasx"];
	
	
	
//Lam viec voi file upload
//	echo dirname($_SERVER["SCRIPT_NAME"]);  //lay duong dan thu muc hien hanh
	
//	$curr_dir = getcwd();  //lay duong dan tuyet doi cua thu muc hien hanh
//	echo $curr_dir;
	

    $root=$_SERVER["DOCUMENT_ROOT"];//Lay duong dan thu muc goc
	
	$uploaddir = $root."/myweb/Images/";
	
	$filename=$_FILES['hinh']['name'];//lay ten file
	//echo $filename;
	
	$pos = strrpos($filename, "." ); 
	//echo $pos;
	
	$fileExtension = substr($filename,$pos);
	//echo $fileExtension;
	
	$hinhsv = $uploaddir.$mssv.$fileExtension; 
	
	
	move_uploaded_file($_FILES['hinh']['tmp_name'],$hinhsv ); 


	//K?t n?i d?n MySQL
	$con=mysql_connect("localhost","root","") or die("Khong the ket noi voi host");
	

	//Ch?n CSDL QLSV
	mysql_select_db("clock",$con) or die("Khong ket noi duoc voi MySQL");
	
	//Chon bang ma la unicode utf-8
	mysql_query("set names 'utf8'");
	
	//Thuc hien cau truy van
//	$query="insert into SINHVIEN values('".$mssv."','".$hoten."','".$ngaysinh."','".$diachi."','".$sdt."','".$makhoa."')";




	$query="insert into nhasx values('".$manhasx."','".$tennhasx."')";
	
	echo $query;

	mysql_query($query,$con);
	
	header("location:nhasx.php");//mo trang lab7.php
?>

